'''
This module contains functions for working with deliverables and tasks relating to events. It is intended to allow third party
modules to quickly and eaily add all the necessary tasks for running an event efficiently.
'''

from datetime import date
from projects.models import Deliverable, Task

def add_event_deliverable(name, objective_id, owner_id, target_date, type_id):
	deliverable = Deliverable()
	deliverable.objective_id = objective_id
	deliverable.title = "Testing adding deliverable from new event called " + name
	deliverable.description = "This deliverable is added as a result of adding a new event from the Event section of the application"
	deliverable.owner_id = owner_id
	deliverable.target_date = target_date
	deliverable.type_id = type_id
	deliverable.save()
	
	task = Task()
	task.title = "Draw up draft agenda"
	task.description = "Agenda\n=====\n\n* Welcome\n* Session 1\n* Session 2\n* Break"
	task.lead_id = owner_id
	task.start_date = date.today()
	task.target_date = target_date
	task.save()
	
	deliverable_tasks.add(task)
	deliverable.save()
	